<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>网上申报第三步</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../../../css/mui.min.css">
		<link rel="stylesheet" href="../../../css/app.css">
		<style>
			.mui-bar-nav~.mui-content{padding:0;margin-top:45px;background:#f5f5f5;}
	        /*头部*/
	       .online_top{width:100%;background:#fff;padding:1rem 0 .1rem 0;}
	       .online_top_cont{width:6.35rem;margin:0 auto;overflow:hidden;}
	       .online_top_cont>img{width:5.5rem;margin:0 .42rem;}
	       .title_list{width:100%;float:left;}
	       .title_list>a{display:block;width:1.2rem;text-align:center;margin-right:.5rem;font-size:.28rem;color:#999;float:left;line-height:.5rem;}
	       .title_list>a:last-child{margin:0;}
	       .title_list>.actives{color:#333;}
	       /*主内容*/
	       .online_cont{width:100%;background:#fff;float:left;position:absolute;top:3.30rem;left:0;height:9.7rem;overflow:auto;}
	       .online_cont>h5{width:100%;float:left;height:.80rem;line-height:.86rem;color:#999;font-size:.32rem;font-weight:normal;background:#f5f5f5;}
		   .online_cont>h5>img{width:.35rem;height:.35rem;float:left;margin:.23rem .1rem 0 .25rem;}
		   .online_lint{width:100%;background:#fff;padding:.3rem .6rem;float:left;}
		   .online_lint>ul{width:100%;float:left;margin:0;padding:0;}
		   .online_lint>ul>li{width:100%;float:left;overflow:hidden;line-height:.4rem;font-size:.24rem;margin-bottom:.1rem;}
		   .online_lint_second{color:#2a558a;}
		   .menu_btn{position:fixed;height:1rem;background:#fff;width:100%;position:fixed;bottom:0;left:0;}
		   .menu_btn>.mui-btn-primary{width:4.1rem;height:.68rem;font-size:.3rem;margin:.15rem 0 0 0;}		
		   .menu_btn>.mui-btn-warning{width:2rem;height:.68rem;font-size:.3rem;background:#ff7800;margin:.15rem 0 0 .65rem;}
		   .bodys_infoss{width:5.8rem;float:left;overflow:hidden;white-space:nowrap;font-size:.2rem;line-height:.4rem;}
		   .online_twos{width:100%;background:#fff;padding:.3rem .25rem .2rem .15rem;box-sizing:border-box;float:left;}
		   .online_twos>img{width:.7rem;height:.7rem;float:left;margin-right:.15rem;}
		   .online_twos>.mui-media-bodys,.online_twos>.bodys_info{width:5.5rem;float:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
		   .online_twos>.mui-media-bodys{font-size:.3rem;line-height:.32rem;margin-top:.06rem;}
		   .online_twos>.bodys_info{font-size:.2rem;line-height:.3rem;}
		   .online_twos>.bodys_info>span{float:left;}
		   .online_twos>.bodys_info>.gray{color:#94969f;margin-right:.27rem;}
		   .online_twos .mui-icon-arrowright{color:#bbbbbb;float:right;margin-top:-.7rem;}
	       /*申请列表*/
	      .online_list{width:100%;float:left;}
	      .online_list .online_list_top{width:7.1rem;float:right;border-bottom:1px solid #eee;position:relative;}
	      .online_list .online_list_top .top_title{width:6.4rem;line-height:.26rem;padding:.3rem 0;float:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-size:.3rem;color:#2a558a;}
	      .online_list .online_list_top .top_title .tij{color:#00d0e9;margin-right:.06rem;}
	      .online_list .online_list_top>i{width:.33rem;height:.085rem;float:left;margin-top:.36rem;background:url(../../../images/work/h_dian.png) no-repeat;background-size:100% 100%;}
	      .online_list .online_list_cont{display:none;background:#efefef;border-radius:.06rem;width:6.75rem;float:left;}
	      .list_cont_box{float:left;width:100%;height:100%;position:relative;padding:.3rem;box-sizing:border-box;position:relative;}
	      .list_cont_box>i{width:.2rem;height:.12rem;position:absolute;top:-.12rem;right:.11rem;background:url(../../../images/work/arrow_gray02.png) no-repeat;background-size:100% 100%;}
	      .list_cont_top{width:100%;float:left;}
	      .list_cont_top>a{display:block;width:1.6rem;float:left;margin-right:.67rem;color:#333;font-size:.28rem;}
	      .list_cont_top>a:last-child{margin-right:0;}
	      .list_cont_top>a>b{width:.3rem;height:.3rem;float:left;margin-right:.08rem;background:url(../../../images/work/zbxz-@2x.png) no-repeat;background-size:100% 100%;margin-top:.05rem;}
	      .list_cont_top>a>.actb{background:url(../../../images/work/zbxzz-@2x.png) no-repeat;background-size:100% 100%;}
	      .list_cont_bottom{width:100%;background:#fff;border-radius:.06rem;padding:.15rem 0 .1rem .3rem;box-sizing:border-box;float:left;margin-top:.25rem;}
	      .list_cont_bottom>b{width:.22rem;height:.25rem;float:left;display:block;margin-right:.1rem;background:url(../../../images/work/block_file.png) no-repeat;background-size:100% 100%;}
	      .list_cont_bottom>span{width:4rem;float:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-size:.26rem;color:#666;line-height:1.3;;}
	      .list_cont_bottom>.btn_cont{float:right;width:1.2rem;margin-top:-.05rem;position:relative;}
	      .list_cont_bottom>.btn_cont>a{display:block;float:left;}
	      .list_cont_bottom>.btn_cont>.mui-icon-download{color:#0b90ac;font-size:.4rem;padding-right:.1rem;position:relative;margin-top:-.01rem;}
	      .list_cont_bottom>.btn_cont>.mui-icon-trash{color:#c20e0e;font-size:.4rem;padding-left:.1rem;}
	      .mui-icon-download:after{position:absolute;right:0;height:.25rem;background-color:#e2e2e2;content:"";width:1px;top:.1rem;}
	      .list_active .online_list_top{border:none;}
	      .list_active .online_list_top>i{width:.08rem;height:.33rem;background:url(../../../images/work/s_dian.png) no-repeat;background-size:100% 100%;margin:.23rem 0 0 .1rem;}
	       /*备注*/
	      .remark{width:100%;float:left;margin:.23rem 0;background:#f5f5f5;padding:.5rem 0;text-align:center;}
	      .mui-checkbox.mui-left label{text-align:left;font-size:14px;padding:11.5px 10px 0 47px;}
	      .mui-checkbox{overflow:visible;}
	      .mui-checkbox input[type=checkbox]:before{font-size:24px;}
	      .mui-checkbox input[type=checkbox], .mui-radio input[type=radio]{top:7px;}
		</style>
	</head>
	<body>
		<!--公共头部-->
		<div class="mui-bar mui-bar-nav" id="header">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"><a class="back"></a></a>
			<h1 class="mui-title">网上申报</h1>
		</div>
		<div class="mui-content" id="content">
		    <div class="online_top">
		    	<div class="online_top_cont">
		    		<img src="../../../images/work/line_three.png">
		    		<div class="title_list">
		    			<a>阅读须知</a>
		    			<a>信息填报</a>
		    			<a class="actives">材料上传</a>
		    			<a>申报告知</a>
		    		</div>
		    	</div>
		    </div>
		    <!--主内容-->
		    <div class="online_cont">
		    	<div class="online_twos" id="correctionBox" style="display: none; padding-bottom: 0px;" > <!---->
		    		<img class="online_twos_img" src="../../../images/work/sb.png">
		    		<div class="mui-media-bodys" style="color: #CF2D28">补齐补正</div>
		    		<br />
		    		<span class="bodys_infoss" id="correctionReason" >
		    		</span>
		    	</div>
		    	<div class="online_twos">
					<img class="online_twos_img" src="../../../images/work/sxmc-@2x.png">
					<div class="mui-media-bodys" id="serviceName"></div>
					<span class="bodys_infoss">
						<span id="lxrName"></span>
						<span class="gray" style="margin-right:0;font-size: 0.2rem;">[申请人]</span>
						<span id="lxrCardno"></span>
						<span class="gray" style="margin-right:0;font-size: 0.2rem;">[身份证号]</span>
					</span>
		    	</div>
		    	<h5><img src="../../../images/work/sltj-@2x.png">申请材料</h5>
		    	<!--申请列表-->
		    	<div id="materia_list_vue">
		    		<div class="online_list" v-for="(mater,index) in materialList">
			    		<div class="online_list_top" 
			    			:materialId = "mater.materialOid" 
			    			:materialType = "mater.materialType"
			    			:mustFlag = "mater.mustFlag" 
			    			:isWindowSubmit = "( mater.materialType == 2 ||  mater.windowSubed == 'Y' ) ? 'N' : 'Y' "
		    				:recOid="mater.recOid"
		    			>
			    			<span class="top_title">
			    				<span class="tij" v-show="mater.materialType != 2">[窗口提交]</span><span v-text="mater.materName + ' ；'"></span>
			    			</span>
			    			<i v-show="mater.materialType == 2" v-on:click="showSubedAtta"></i>
			    			<div class="online_list_cont">
			    				<div class="list_cont_box">
			    					<i v-show="mater.materialType == 2"></i>
				    				<div class="list_cont_top">
				    					<a v-on:click="subMateria(1,index , $event)" ><b v-bind:class="{'actb':actb(mater.windowSubed)}"></b>窗口提交</a>
				    					<a v-on:click="subMateria(2,index ,$event)" v-show="mater.materialType == 2">材料上传</a>
				    					<a v-on:click="subMateria(3,index ,$event)" v-show="mater.materialType == 2">证照库选择</a>
				    				</div>
				    				<template v-for=" (atta,inedx_) in mater.attas">
					    				<div class="list_cont_bottom" 
					    						:caseAttaId = "atta.attaId" 
					    						:licenseNumber="atta.licenseNumber" 
					    						:selfLicenseId="atta.selfLicenseId"
					    						:trueId="atta.trueId"
			    						>
					    					<b></b>
					    					<span v-text="atta.fileOriginalName"></span>
					    					<div class="btn_cont">
					    						<!--<a class="mui-icon mui-icon-download"></a>-->
					    						<a v-on:click="deleteAtta($event,index)" class="mui-icon mui-icon-trash"></a>
					    					</div>
					    				</div>
				    				</template>
			    				</div>
			    			</div>
			    		</div>
			    	</div>
		    	</div>
			    <!--备注-->
		        <div class="remark">
		        	<div class="mui-input-row mui-checkbox mui-left">
						<label>注：本人对办理该事项提交的申请材料内容真实性负责。</label>
						<input name="responsible" value="Item 1" type="checkbox" >
					</div>
		        </div>
		    </div>
		</div>
		<div class="menu_btn">
			<button type="button" saveDraftFlag = "Y" class="mui-btn mui-btn-warning">暂存</button>
			<button type="button" saveDraftFlag = "N" class="mui-btn mui-btn-primary">提交</button>
		</div>
		
		<script>
			var my_immersed = function(immersed) {
				document.getElementById("header").style.paddingTop = immersed + 'px';
				document.getElementById("header").style.height = (immersed + 44)+'px';
				//document.getElementById("content").style.paddingTop = (immersed + 44) + 'px';
			}
		</script>
		<script type="text/javascript" src="../../../js/immersed.js" ></script>
		<script type="text/javascript" src="../../../js/mui.min.js"></script>
		<script type="text/javascript" src="../../../js/jquery2.2.4.min.js"></script>
		<script type="text/javascript" src="../../../js/common.js"></script>
		<script type="text/javascript" src="../../../js/app.js" ></script>
		<script type="text/javascript" src="../../../js/vue.min.js" ></script>
		<script type="text/javascript" src="../../../js/cutImg.js" ></script>
		<script type="text/javascript" src="../../../js/file.js" ></script>
		<script>
			(function(mui,$){
				var serviceId,caseOid,userId,materiaListVue,caseCorrectionOid,correctionReason;;
				mui.init();
				mui.back = function(){
					//返回时 更新上一步的caseId,防止重复提交
					mui.fire(plus.webview.currentWebview().opener(),'setp3Back',{
						caseId:caseOid
					});
					plus.webview.currentWebview().opener().show();
					plus.webview.currentWebview().hide("zoom-fade-in");
				}
				mui.plusReady(function(){
					serviceId = plus.webview.currentWebview().serviceId;
					caseOid = plus.webview.currentWebview().caseOid;
					//判断 是否不起补正
					caseCorrectionOid = plus.webview.currentWebview().caseCorrectionOid;
					correctionReason = plus.webview.currentWebview().correctionReason;
					if(caseCorrectionOid){//是补齐补正
						$("#correctionReason").text(correctionReason);
						$("#correctionBox").show();
						$(".menu_btn").find('[saveDraftFlag=Y]').addClass('mui-disabled');
					}
					userId = getUserId();
					if(!serviceId || !caseOid) {
						mui.alert('无法获取办件信息','错误',"",function(){
							mui.back();
						},'div')
					}
					getBaseInfo(userId,serviceId);
					closeWaitingAndShowView(); 
					materiaListVue = createMaterVM();//材料模板
					createMaterias(materiaListVue);//组成材料
				})
				
				mui('.menu_btn').on('tap','.mui-btn',function(){
					var saveDraftFlag = this.getAttribute('saveDraftFlag');
					if($(this).hasClass('mui-disabled')){
						if(saveDraftFlag == "Y" && caseCorrectionOid){
							mui.toast("补齐补正办件暂不支持暂存 ")
						}
						return
					} 
					if(saveDraftFlag == 'N'){//提交
						if(!$("input[name = responsible]").is(':checked')){
							mui.toast('请确认信息的真实性');
							return;
						}
					}
					subRequest(saveDraftFlag);
				})
				
				//获取基本信息
				var getBaseInfo = function(userId,serviceId){
					var data = localStorage.getItem(userId+"-"+serviceId)
						?JSON.parse(localStorage.getItem(userId+"-"+serviceId)):null;
					if(data){
						var user = data.user;
						var service = data.service;
						$("#lxrName").text(user.lxrName);
						$("#lxrCardno").text(user.lxrCardno);
						$("#serviceName").text(service.serviceName);
					}
				}
				//提交申请
				var subRequest = function(saveDraftFlag){
					var url = "appNetCase/saveRegStep3.do";
					var recFormJson =  getMateriasJson(saveDraftFlag) ; 
					var param ={
						saveDraftFlag:saveDraftFlag,
						userId:userId,
						caseOid:caseOid,
						recFormJson:JSON.stringify(recFormJson)
					}
					if(caseCorrectionOid){//保存不起补正信息
						url = "appNetCase/saveCaseCirrection.do";
						param ={
							saveDraftFlag:saveDraftFlag,
							userId:userId,
							caseOid:caseOid,
							recFormJson:JSON.stringify(recFormJson)
						}
					}
					if(!recFormJson) return;
					utils.ajax(url,function(data){
						data = JSON.parse(data);
						if(data.state == 1){
							if(saveDraftFlag == 'Y'){//暂存
								plus.webview.getWebviewById('netCase/caseRegStep1') &&
									plus.webview.getWebviewById('netCase/caseRegStep1').close();
								plus.webview.getWebviewById('netCase/caseRegStep2') && 
									plus.webview.getWebviewById('netCase/caseRegStep2').close()
								mui.toast('保存成功!')
								plus.webview.getWebviewById('netCase/caseRegStep3').hide();
								plus.webview.getWebviewById('netCase/caseRegStep3').close('zoom-fade-in',300);
							}else{
								if(caseCorrectionOid){
									mui.alert("补正成功",null,null,function(){
										plus.webview.getWebviewById('netCase/caseRegStep2') && plus.webview.getWebviewById('netCase/caseRegStep2').close() ;
										plus.webview.currentWebview().close('zoom-fade-in');
									},"div")
								}else{
									openNewWin(
										"_www/src/work/netCase/caseRegStep4.html",
										null,
										'netCase/caseChooseRec',
										{
											caseNum:data.caseNum,
											caseOid:caseOid,
											serviceId:serviceId
										}
									)
								}
							}
						}else{
							mui.toast(data.msg?data.msg:"保存申报信息异常,请重试");
						}
					},jsonToParams(param,true),{showWait:true})
				}
				//将材料组合成json
				var getMateriasJson = function(saveDraftFlag){
					var recFormList = {};
					var materiaDom = $(".online_list").find(".online_list_top");
					for(var i = 0;i<materiaDom.length;i++){
						var recOid = $(materiaDom[i]).attr('recOid');//事项材料关联表OID
						var materialType = $(materiaDom[i]).attr('materialType');
						
						if(materialType != '2'){//窗口提交
							recFormList[$(materiaDom[i]).attr('materialId')] = {
								isWindowSubmit:"Y",
								materialId:$(materiaDom[i]).attr('materialId'),
								caseId:caseOid
							}
						}else {//非默认窗口提交时
							if( $(materiaDom[i]).find('.list_cont_top a b').hasClass('actb') ){//
								recFormList[$(materiaDom[i]).attr('materialId')] = {
									isWindowSubmit:"Y",
									materialId:$(materiaDom[i]).attr('materialId'),
									caseId:caseOid
								}
							}else{
								var mustFlag = $(materiaDom[i]).attr('mustFlag');
								var attaDoms = $(materiaDom[i]).find('.list_cont_bottom');
								//暂存不需要控制
								if(saveDraftFlag !='Y' && mustFlag == 0 && attaDoms.length < 1){
									mui.toast("第"+ (i+1) + "条材料需要上传");
									return false;
								}
								if(attaDoms.length < 1){//暂存时 如果没有已上传资料
									recFormList[$(materiaDom[i]).attr('materialId')] = {
										materialId:$(materiaDom[i]).attr('materialId'),
										caseId:caseOid
									}
								}else{//如果有材料 则需要操作json
									var caseAttaId = "",selfLicenseId = "",licenseNumber = "";
									for(var j = 0 ; j < attaDoms.length ; j++){
										//上传的材料
										if($(attaDoms[j]).attr("caseAttaId")){
											caseAttaId += $(attaDoms[j]).attr("caseAttaId") + (j < attaDoms.length -1 ? ",":"");
										}
										//自定材料
										if($(attaDoms[j]).attr("selfLicenseId")){
											selfLicenseId += $(attaDoms[j]).attr("selfLicenseId") + (j < attaDoms.length -1 ? ";":"");
										}
										//证照库材料
										if($(attaDoms[j]).attr("licenseNumber")){
											licenseNumber += $(attaDoms[j]).attr("licenseNumber");
										}
									}
									recFormList[$(materiaDom[i]).attr('materialId')] = {
										isWindowSubmit:"N",
										materialId:$(materiaDom[i]).attr('materialId'),
										caseId:caseOid,
										caseAttaId:caseAttaId,
										selfLicenseId:selfLicenseId,
										licenseNumber:licenseNumber
									}
								}
							}
							
						}
						recOid && (recFormList[$(materiaDom[i]).attr('materialId')].oid = recOid) ;
					}
					return recFormList;
				}
				
				//组成材料
				var createMaterias = function(materiaListVue){
					var url = "appNetCase/initNetCase.do";  
					utils.ajax(url,function(data){
						data = JSON.parse(data);
						if(data.state = 1){
							materiaListVue.materialList = data.materialList ;
						}else{
							mui.toast("");
						}
					},jsonToParams({
						serviceId:serviceId,
						caseOid:caseOid
					}),{showWait:true})
				}
				//生成vm
				var createMaterVM = function (){
					return new Vue({
						el:"#materia_list_vue",
						data:{
							materialList:[]
						},
						methods:{
							actb:function(windowSubed){
								return windowSubed=="Y"
							},
							//" ... " 按钮
							showSubedAtta:function(event){
								var el = event.currentTarget;
								if($(el).parents('.online_list').hasClass('list_active')){
									$(el).parents('.online_list').removeClass('list_active');
									$('.online_list_cont').hide();
								}else{
									$('.online_list').removeClass('list_active');
								    $(el).parents('.online_list').addClass('list_active');
								    $('.online_list_cont').hide();
								    $(el).parents('.online_list').find('.online_list_cont').slideDown(150);
								}
							},
							//材料上传方式
							subMateria:function(type,index,event){
								var el = event.currentTarget;
								$(el).addClass('active');
								if(type == "1"){//窗口上传
									if(!$(el).find('b').hasClass('actb')){
										$(el).find('b').addClass('actb');
										$(el).parents('.online_list_top').attr('isWindowSubmit',"Y");
									}else{
										$(el).find('b').removeClass('actb');
										$(el).parents('.online_list_top').attr('isWindowSubmit',"N");
									}
								}else{
									if($(el).parent().first().find('b').hasClass('actb')){
										$(el).parent().first().find('b').removeClass('actb');
									}
									$(el).parents('.online_list_top').attr('isWindowSubmit',"N");
									if(type == "2"){//材料上传
										subMateriaType2(this,event,index);
									}else if(type == "3"){//证照库
										var materialId = $(el).parents('.online_list_top').attr('materialId');
										chooseFileFromLibrary(index);
									}
								}
							},
							//删除材料
							deleteAtta:function(event,index){//删除已上传的文件
								plus.nativeUI.confirm('确认删除么?',function(e){
									if(e.index == 1) return;
									var el = event.target;
									var li = $(el).parent().parent();
									var caseAttaId = li.attr('caseAttaId');
									var licenseNumber = li.attr('licenseNumber');
									var selfLicenseId = li.attr('selfLicenseId');
									//剔除出vue 中的信息
									var attas = materiaListVue.materialList[index].attas;
									var arr = new Array();
									for(var i = 0;i<attas.length;i++){
										if(caseAttaId){
											if(attas[i].attaId != caseAttaId) arr.push(attas[i]);
										}else if(licenseNumber){
											if(attas[i].licenseNumber != licenseNumber) arr.push(attas[i]);
										}else if(selfLicenseId){
											if(attas[i].selfLicenseId != selfLicenseId) arr.push(attas[i]);
										}
									}
									if(caseAttaId){
										var url = "appNetCase/deleteNatCaseAtta.do";
										utils.ajax(url,function(data){
											data = JSON.parse(data);
											if(data.state = 1){
												mui.toast('删除成功');
												//去除 vue中的数据
												materiaListVue.materialList[index].attas = arr; 
												Vue.set(materiaListVue.materialList,index, materiaListVue.materialList[index]);
											}else{
												mui.alert(data.msg?data.msg : "删除失败",'错误');
											}
										},jsonToParams({attaOid:caseAttaId,caseOid:caseOid}),{showWait:true})
									}else{
										//去除 vue中的数据
										materiaListVue.materialList[index].attas = arr; 
										Vue.set(materiaListVue.materialList,index, materiaListVue.materialList[index]);
									}
								})//delete end
							}
						}
					})
				}
				/**
				 * 从证照库选择文件
				 */
				var chooseFileFromLibrary = function(index){
					
					openNewWin("caseAttaByLibrary.html", null, 'caseAttaByLibrary.html',{
						beforeViewId:plus.webview.currentWebview().id,
						index:index
					})
					
					//openNew('caseAttaByLibrary.html','caseAttaByLibrary.html',{beforeViewId:plus.webview.currentWebview().id,index:index},true,false,{hardwareAccelerated:true});
				
				}
				//文件上传
				var subMateriaType2 = function(vue,event,index){
					index = parseInt(index);
					var options = {
						'url': 'appNetCase/uploadNetCaseAtta.do',
						'success': uploadSuccess,
						datas:{
							caseOid:caseOid
						},
						'fail': upLoadFild,
						showWait:true
					}
					getImageWay(false,"选择文件",function(entry){
						options.filepath = entry;
						uploadFile(options);
					})
					//上传成功回调
					function uploadSuccess (t,ele) {
						var data = JSON.parse(t.responseText);
						console.log(JSON.stringify(data.attas));
						if(data.state == '1' && data.attas[0].success) {
							if(vue.materialList[index].attas){
								data.attas = data.attas.concat(vue.materialList[index].attas)
							}
							vue.materialList[index].attas = data.attas;
							Vue.set(vue.materialList,index, vue.materialList[index]);
						}else {
							mui.toast(data.msg?data.msg:'上传失败请重试 !');
						}
					}
					//上传失败回调
					function upLoadFild() { 
						mui.toast('上传失败请重试 !');
					}
				}
				document.addEventListener('selectedFromLibrary',function(e){
					var librarys = e.detail.librarys;
					if(librarys && librarys.length >0){
						var index = e.detail.index;
						if(materiaListVue.materialList[index].attas){
							var attas = materiaListVue.materialList[index].attas;
							//循环 libray 覆盖证照库
							var newlicenseNumber = "";
							for ( var i = 0;i< librarys.length ;i++ ) {
								if( ! librarys[i] ) continue;
								if( librarys[i].licenseNumber ){ // 记录新的证照库id
									newlicenseNumber = librarys[i].licenseNumber;
								}
								for( var j = 0;j< attas.length ; j++ ){
									if( ! attas[j] ) continue;
									/*if( librarys[i].licenseNumber 
										&& attas[j].licenseNumber 
										&& librarys[i].licenseNumber == attas[j].licenseNumber ){
										delete attas[j];//剔除 attas 中的重复数据
									}else*/
									
									 if( librarys[i].selfLicenseId 
										&& attas[j].selfLicenseId 
										&& librarys[i].selfLicenseId == attas[j].selfLicenseId ){
										delete attas[j];//剔除 attas 中的重复数据 //为代码易读
									}
								}
							}
							var arr = new Array();
							for( var j = 0;j< attas.length ; j++ ){
								if(!attas[j]) continue;
								if(newlicenseNumber){// 证照只有一个文件
									if( ! attas[j].licenseNumber){
										arr.push(attas[j]); 
									}
								} else{
									arr.push(attas[j]); 
								}
							}
							librarys = librarys.concat(arr);
						}
					 	materiaListVue.materialList[index].attas = librarys;
						Vue.set(materiaListVue.materialList,index, materiaListVue.materialList[index]);
					}
				})
			}(mui,jQuery))
		</script>
	</body>

</html>
